package com.foodndate.food.food;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.foodndate.food.taste.TasteDao;
import com.foodndate.food.taste.TasteDto;

@Controller
public class FoodController {

	
	@Autowired
	private TasteDao tastedao;
	//맛집 전체 리스트
	@RequestMapping(value = "food/tasteview", method = RequestMethod.GET)
	public String tasteview(Model model, TasteDto tastedto) {
		List foodlist = tastedao.list(tastedto);
		model.addAttribute("foodlist", foodlist);
		return "food/foodlist";
	}
	//맛집 카테고리 리스트
	@RequestMapping(value="food/categorylist", method=RequestMethod.GET)
	public String categorylist(HttpSession session,TasteDto tastedto,Model model){
		
		System.out.println("category");
		System.out.println("푸드_카테고리 : "+tastedto.getFood_category());
		System.out.println("푸드 구조회 :"+tastedto.getFood_area1());
		
		tastedto.setFood_area1("%"+tastedto.getFood_area1()+"%");
		System.out.println(tastedto.getFood_area1());
		
		
		List<TasteDto> foodlist = tastedao.categorylist(tastedto);
		
			
		model.addAttribute("foodlist", foodlist);
		model.addAttribute("tastedto", tastedto);
		return "food/foodlist";
	}
	/*//맛집 카테고리 && 구별 리스트
	@RequestMapping(value="food/arealist", method=RequestMethod.GET)
	public String arealist(TasteDto tastedto, Model model){
		System.out.println("맛집 카테고리 && 구별 리스트");
		System.out.println("구 조회 : " +tastedto.getFood_area1() );
		
		List arealist=tastedao.arealist(tastedto);
		System.out.println("arealist size : " +arealist.size());
		System.out.println("카테고리" + tastedto.getFood_category());
		System.out.println("구" + tastedto.getFood_area1());
		return "food/arealist";
	}*/
	//맛집 상세보기
	@RequestMapping(value = "food/fooddetail", method = RequestMethod.GET)
	public String fooddetail(TasteDto tastedto, Model model) {

		System.out.println("맛집번호" + tastedto.getFood_num());
		
		tastedto = tastedao.fooddetail(tastedto);
		
		System.out.println(tastedto.getFood_area2());
		System.out.println(tastedto.getFood_area1());
		System.out.println(tastedto.getFood_name());
		model.addAttribute("tastedto", tastedto);
				
		return "food/fooddetail";
	}
/*	
	//맛집 카테고리 && 구별 리스트 테슽크
	@RequestMapping(value="food/arealist", method=RequestMethod.GET)
	public String arealistTest( Model model,sDto sdto){
		System.out.println("테스트 입니다 ");
		tastedao.arealistTest(sdto);
		
		return "food/arealist";
	}*/
	
}
